package com.pignest.hotel.module.user.ui;

import java.util.List;

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;

import com.pignest.framework.util.Utils;
import com.pignest.hotel.beans.MemberLevel;

import com.pignest.hotel.service.MemberService;
import com.pignest.hotel.spring.Services;
import com.pignest.hotel.util.MoneyUtil;

public class MemberLevelListBox extends Listbox implements EventListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2497260204511618300L;
	private MemberService memberService;
	private Listbox memberLevelSetList;

	public MemberLevelListBox(){
		memberService = Services.getMemberService();
		addEventListener("onCreate", this);
	}
	@Override
	public void onEvent(Event event) throws Exception {
		// TODO Auto-generated method stub
		if ("onCreate".equals(event.getName())) {
			memberLevelSetList =(Listbox)getFellow("memberLevelSetList");
			query();
		}
	}
	public void query(){
		memberLevelSetList.getItems().clear();
		List<MemberLevel> list =memberService.QueryMemberLevel();
		for(MemberLevel l:list){
    		Listitem listitem = new Listitem();
	    	listitem.setParent(memberLevelSetList);
	    	listitem.setValue(l.getId());
	    	listitem.appendChild(new Listcell(""));
	    	listitem.appendChild(new Listcell(l.getMemberlevel()));
	    	listitem.appendChild(new Listcell(Utils.toPrice(l.getOverdraft())));
	    	listitem.appendChild(new Listcell(l.getSelfhelplive()));
	    	listitem.appendChild(new Listcell(l.getSelfhelpout()));
	    	listitem.appendChild(new Listcell(Utils.toPrice(l.getLevelPrice())));
	    	listitem.appendChild(new Listcell(Utils.toPrice(l.getLevelPay())));
	    	Integer i =l.getLevelIntegal();
	    	if(i!=null)
	    	 listitem.appendChild(new Listcell(i.toString()));
	    	else
	    		listitem.appendChild(new Listcell("0"));
	    	
	    	
    	}
	}

}
